<?php 
	//print_r($current_page);
	$start_number = (($current_page -1 ) * $default_per_page) ;
	if($start_number <= 0)
		$start_number = 0;
	$column_width = (int)(80/count($columns));
	
	if(!empty($list)){
?><div class="bDiv" >
		<table cellspacing="0" cellpadding="0" border="0" id="flex1">
		<thead>
			<tr class='hDiv ui-accordion-header ui-helper-reset ui-state-default ui-corner-all ui-accordion-icons'>
				<?php if(!$unset_numbering){?>
				<th align="center" valign="middle" abbr="number" axis="col1" class="numbering" width='2%'>
					<div class="">
						<?php echo $this->l('list_numbering'); ?>
					</div>
				</th>
				<?php }?>
				<?php foreach($columns as $column){?>
				<th width='<?php echo $column_width?>%'  valign="middle" >
					<div class="text-left field-sorting <?php if(isset($order_by[0]) &&  $column->field_name == $order_by[0]){?><?php echo $order_by[1]?><?php }?>" 
						rel='<?php echo $column->field_name?>'>
						<?php echo $column->display_as?>
					</div>
				</th>
				<?php }?>

				<?php if(!$unset_delete || !$unset_edit || !$unset_read || !empty($actions)){?>
				<th align="left" abbr="tools" axis="col1" class="" width='10%'  valign="middle" >
					<div class="">
						<?php echo $this->l('list_actions'); ?>
					</div>
				</th>
				<?php }?>
				
			</tr>
		</thead>		
		<tbody>
		<?php foreach($list as $num_row => $row){ $start_number++?>        
		<tr class="tr-<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>" tid="<?php echo $row->id ?>"  <?php if($num_row % 2 == 1){?>class="erow"<?php }?>>
			
			<?php if(!$unset_numbering){?>
			<td align="center" width='2%'>
				<div style="text-align:center">
					<?php echo $start_number; ?>
				</div>
			</td>
			<?php }?>
			<?php foreach($columns as $column){?>
			<td width='<?php echo $column_width?>%' class='<?php if(isset($order_by[0]) &&  $column->field_name == $order_by[0]){?>sorted<?php }?>'>
				<div class='text-left'><?php echo $row->{$column->field_name} != '' ? $row->{$column->field_name} : '&nbsp;' ; ?></div>
			</td>
			<?php }?>
			
			<?php if(!$unset_delete || !$unset_edit || !$unset_read || !empty($actions)){?>
			<td align="left" width='10%'>
				<div class='tools action-<?php echo strtolower(preg_replace('/\s/i', '-', $subject))?>' style=" width: 64px; margin: 0px auto;">				
					<?php if(!$unset_delete){?>
                    	<a href='<?php echo $row->delete_url?>' title='<?php echo $this->l('list_delete')?> <?php echo $subject?>' class="delete-row" >
                    			<span class='delete-icon  ui-corner-all ui-icon ui-icon-trash'></span>
                    	</a>
                    <?php }?>
                    <?php if(!$unset_edit){?>
						<a onclick="query_form(this)" href='<?php echo $row->edit_url?>' title='<?php echo $this->l('list_edit')?> <?php echo $subject?>' class="edit_button"><span class='edit-icon ui-corner-all ui-icon ui-icon-pencil'></span></a>
					<?php }?>
					<?php if(!$unset_read){?>
						<a onclick="query_form(this)" href='<?php echo $row->read_url?>' title='<?php echo $this->l('list_view')?> <?php echo $subject?>' class="edit_button"><span class='read-icon  ui-corner-all ui-icon ui-icon-document'></span></a>
					<?php }?>
					<?php 
					if(!empty($row->action_urls)){
						foreach($row->action_urls as $action_unique_id => $action_url){ 
							$action = $actions[$action_unique_id];
					?>
							<a style="float:left" href="<?php echo $action_url; ?>" class="<?php echo $action->css_class; ?> " title="<?php echo $action->label?>"><?php 
								if(!empty($action->image_url)){ 
												$is_image = !empty($action->image_ur) &&
															( substr($action->image_ur,-4) == '.jpg'
																	|| substr($action->image_ure,-4) == '.png'
																	|| substr($action->image_ur,-5) == '.jpeg'
																	|| substr($action->image_ur,-4) == '.gif'
																	|| substr($action->image_ur,-5) == '.tiff')
														? true : false;
											?>
												<?php if($is_image) {?>
												<img src="<?php echo $action->image_url; ?>" alt="" />
												<?php } else { echo $action->image_url?>

												<?php }?>
											<?php
											}
							?></a>		
					<?php }
					}
					?>					
                    <div class='clear'></div>
				</div>
			</td>
			<?php }?>
		</tr>
<?php } ?>        
		</tbody>
		</table>
	</div>
<?php }else{?>
	<br/>
	&nbsp;&nbsp;&nbsp;&nbsp; <?php echo $this->l('list_no_items'); ?>
	<br/>
	<br/>
<?php }?>	
<script type="text/javascript">
function query_form(el){
    var grid_cls ='.grd-<?php echo strtolower(str_replace(' ', '-', $subject))?>';
    var grid_obj ='grd_<?php echo strtolower(str_replace(' ', '_', $subject))?>';
	if(typeof window[grid_obj] != 'undefined')
	if(typeof window[grid_obj]['QueryForm'] != 'undefined'){
		window[grid_obj]['QueryForm'].Reset = true;
		window[grid_obj]['QueryForm']();
	}
	////console.log(window[grid_obj])
}
//$(document).ready(function(){

	// $(grid_cls+' .add_button,'+grid_cls+' .edit_button').each(function(){
	// 	$(this).click(function(){
			
	// 	});
	// })
//})
</script>